package com.rabbit.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @Author 咕唧
 * @Date 2022/6/22 22:01
 * @Version 1.0
 */
public class ConnectionUtils {

    public static Connection getConnection() throws IOException, TimeoutException {
        //获取连接
        ConnectionFactory factory = new ConnectionFactory();
        //设置地址
        factory.setHost("120.48.95.238");
        factory.setPort(5672);
        factory.setUsername("test");
        factory.setPassword("123");
        factory.setVirtualHost("/haha");
        //创建新的连接
        return factory.newConnection();
    }

}
